#include "precompiled.h"
#include "itemcombobox.h"
using namespace std;
using namespace weo::ui;
using namespace weo::engine;
using namespace weo::engine::item;
using namespace weo::engine::character;
using namespace weo::engine::utility;
using namespace weo::engine::optimization;

template<typename T>
bool ItemComboBox<T>::eventhandler(QEvent *event)
{
    if (event->type() == QEvent::ToolTip)
    {
        QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
        const T* item = getCurrentItem();
        if(item)
        {
            std::string tt = Utility::toRichText<T>(*item);
            QToolTip::showText(helpEvent->globalPos(), tr(tt.c_str()));
        }
    }
    return QWidget::event(event);
}
template<>
bool ItemComboBox<Item>::event(QEvent *event)
{
    return eventhandler(event);
}
template<>
bool ItemComboBox<Enchant>::event(QEvent *event)
{
    return eventhandler(event);
}
